package com.rfid.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.rfid.domain.VO.HouseChildVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.rfid.domain.RfidHouseChild;
import com.rfid.service.IRfidHouseChildService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓库分区信息Controller
 * 
 * @author ruoyi
 * @date 2022-12-28
 */
@RestController
@RequestMapping("/rfid/child")
public class RfidHouseChildController extends BaseController
{
    @Autowired
    private IRfidHouseChildService rfidHouseChildService;

    /**
     * 查询仓库分区信息列表
     */
    @PreAuthorize("@ss.hasPermi('rfid:child:list')")
    @GetMapping("/list")
    public TableDataInfo list(RfidHouseChild rfidHouseChild)
    {
        startPage();
        List<HouseChildVO> list = rfidHouseChildService.selectHouseChildVOList(rfidHouseChild);
        return getDataTable(list);
    }

    /**
     * 导出仓库分区信息列表
     */
//    @PreAuthorize("@ss.hasPermi('rfid:child:export')")
//    @Log(title = "仓库分区信息", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, RfidHouseChild rfidHouseChild)
//    {
//        List<HouseChildVO> list = rfidHouseChildService.selectHouseChildVOList(rfidHouseChild);
//        ExcelUtil<HouseChildVO> util = new ExcelUtil<HouseChildVO>(HouseChildVO.class);
//        util.exportExcel(response, list, "仓库分区信息数据");
//    }

    /**
     * 获取仓库分区信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('rfid:child:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(rfidHouseChildService.selectRfidHouseChildById(id));
    }

    /**
     * 新增仓库分区信息
     */
    @PreAuthorize("@ss.hasPermi('rfid:child:add')")
    @Log(title = "仓库分区信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RfidHouseChild rfidHouseChild)
    {
        return toAjax(rfidHouseChildService.insertRfidHouseChild(rfidHouseChild));
    }

    /**
     * 修改仓库分区信息
     */
    @PreAuthorize("@ss.hasPermi('rfid:child:edit')")
    @Log(title = "仓库分区信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RfidHouseChild rfidHouseChild)
    {
        return toAjax(rfidHouseChildService.updateRfidHouseChild(rfidHouseChild));
    }

    /**
     * 删除仓库分区信息
     */
    @PreAuthorize("@ss.hasPermi('rfid:child:remove')")
    @Log(title = "仓库分区信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rfidHouseChildService.deleteRfidHouseChildByIds(ids));
    }
}
